<!-- 
  computed
 -->

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Learn Vue</title>
</head>
<body>
  <div id="app">
    <!-- 目前是2个，如果多个呢？10个， 100个拼接？？ -->
    <h2>{{firstName + ' ' + lastName}}</h2>
    <h2>{{firstName}} {{lastName}}</h2>

    <!-- 方法一 -->
    <h2>{{getFullName()}}</h2>

    <!-- 计算属性 -->
    <h2>{{fullName}}</h2>
  </div>

  <script src="../../js/vue.js"></script>
  <script>
    const app = new Vue({
      el: '#app',
      data: {
        firstName: 'lebron',
        lastName: 'james'
      },
      methods: {
        getFullName: function() {
          return this.firstName + ' ' +this.lastName;
        }
      },
      computed: { //计算属性(尽量不要 写get)
        fullName: function() {
          return this.firstName + '' +this.lastName; 
        }
      }
    })
  </script>
</body>
</html>